package com.hua.demo.edu.controller;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hua.R;
import com.hua.demo.edu.entity.Video;
import com.hua.demo.edu.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author huazi
 * @since 2021-11-24
 */
@RestController
@RequestMapping("/edu/video")
public class VideoController {
    @Autowired
    private VideoService videoService;
    //增加小节
    @PostMapping("addvideo")
    public R addvideo(@RequestBody Video video){
        boolean save = videoService.save(video);
        if(save)
            return R.ok();
        else
            return R.error();
    }
    //删除小节
    @DeleteMapping("delete/{videoid}")
    public R deletevideo(@PathVariable String videoid){
        boolean b = videoService.removeById(videoid);
        if(b)
            return R.ok();
        else
            return R.error();
    }
    //更新小节
    @PostMapping("updatevideo")
    public R updatevideo(@RequestBody Video video){
        boolean update = videoService.updateById(video);
        if(update)
            return R.ok();
        else
            return R.error();
    }

}

